﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using RPGXEngine;
using RPGX.Graphics;

namespace RPGX.Scripting.SystemFunctions
{
    public static class SystemFunction_HUDTextAreaSetKey
    {
        public static IVariableType Method(ScriptManager sm, FunctionScope scope, List<IVariableType> data)
        {
            if (data == null || data.Count != 2)
                return sm.Zero;

            IVariableType res = sm.True;

            string id = data[0].Value.ToString();
            string key = data[1].Value.ToString();

            try
            {
                if (Game1.Instance.HUD.ObjectsById.ContainsKey(id))
                {
                    HUDObject_TextArea ta = Game1.Instance.HUD.ObjectsById[id] as HUDObject_TextArea;
                    if (ta != null)
                    {
                        ta.Key = key;
                    }
                }
            }
            catch (Exception)
            {
                res = sm.False;
            }

            return res;
        }
    }
}
